<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateComDictsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('com_dicts'))
        {
            Schema::create('com_dicts', function (Blueprint $table)
            {
                $table->string('id', 45)->primary()->comment('ID');
                $table->string('type_id', 45)->comment('类型');
                $table->string('code', 45)->comment('代码');
                $table->string('name', 45)->comment('名称');
                $table->string('value', 200)->nullable()->comment('值');
                $table->integer('sort')->nullable()->default(0)->comment('排序');
                $table->timestamps();
                $table->foreign('type_id')->references('id')->on('com_dict_types')->onDelete('cascade');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('com_dicts');
    }
}
